home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / dbase / vpi1_330.zip / BIT.PRG < prev    next >
Text File  |  1991-12-30  |  1KB  |  40 lines

  1. ***************************************************************************
  2. **  BIT.PRG
  3. **  (C) Copyright 1990-92, Sub Rosa Publishing Inc.
  4. **
  5. **  A demonstration program provided to VP-Info users.
  6. **  This program may be copied freely. If it is used in commercial code,
  7. **  please credit the source, Sub Rosa Publishing Inc.
  8. **
  9. **  BIT demonstrates the use of BIT( function to generate the binary
  10. **  code for characters.
  11. **
  12. **  BIT is compatible with all current versions of VP-Info.
  13. **
  14. **  Sid Bursten and Bernie Melman
  15. ***************************************************************************
  16. WINDOW
  17. CLS
  18. SET RAW ON   ; eliminates spaces between listed output
  19. DO WHILE t   ; perpetual loop terminated by BREAK command
  20.    ACCEPT 'Enter a short string for binary representation: ' TO string
  21.    IF string=' '
  22.       BREAK
  23.    ENDIF
  24.    ?
  25.    REPEAT (LEN(string)*8) TIMES VARYING position ; 8 bits * number of chars
  26.       BIT_VAL =  IFF(BIT(string,position),1,0) ; note use of IFF( function
  27.       ?? str(bit_val,1,0) ; .. and STR( to format output
  28.       IF MOD(position,8)=0 ; .. and MOD( to space between characters
  29.          IF col()>60
  30.             ?
  31.          ELSE
  32.             ?? ' '
  33.          ENDIF
  34.       ENDIF
  35.    ENDREPEAT
  36. ENDDO
  37. CHAIN samples
  38. *
  39. *                          *** end of BIT.PRG ***
  40.